/* 
 * Copyright (c) 2008 Knightsoft
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
*/
package com.knightsoft.util;

/**
 * Array creation methods that can be used without
 * qualifiers, using Java SE5 static imports:
 * 
 * @version V1.0 Nov 10, 2008
 * @author Michael
 */
public class Range {
	// Produce a sequence [0..n)
	public static int[] range(int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++)
			result[i] = i;
		return result;
	}

	// Produce a sequence [start..end)
	public static int[] range(int start, int end) {
		int sz = end - start;
		int[] result = new int[sz];
		for (int i = 0; i < sz; i++)
			result[i] = start + i;
		return result;
	}

	// Produce a sequence [start..end) incrementing by step
	public static int[] range(int start, int end, int step) {
		int sz = (end - start) / step;
		int[] result = new int[sz];
		for (int i = 0; i < sz; i++)
			result[i] = start + (i * step);
		return result;
	}
}
